#ifndef __NT_TYPES__
#define __NT_TYPES__

namespace xm
{
	typedef UINT32	PTR32;
	typedef UINT64	PTR64;

	static const PTR32	USER_SHARE_DATA_BASE_32 = 0x777FE000;
	static const PTR64	USER_SHARE_DATA_BASE_64 = 0x777FFFFFE000;

	typedef struct _UNICODE_STRING32 {
		USHORT Length;
		USHORT MaximumLength;
		PTR32 Buffer;
	} UNICODE_STRING32;

	typedef struct _UNICODE_STRING64 {
		USHORT Length;
		USHORT MaximumLength;
		PTR64 Buffer;
	} UNICODE_STRING64;

	typedef struct _LIST_ENTRY32 {
		PTR32 Flink;
		PTR32 Blink;
	} LIST_ENTRY32, *PLIST_ENTRY32, *RESTRICTED_POINTER PRLIST_ENTRY32;

	typedef struct _LIST_ENTRY64 {
		PTR64 Flink;
		PTR64 Blink;
	} LIST_ENTRY64, *PLIST_ENTRY64, *RESTRICTED_POINTER PRLIST_ENTRY64;

	typedef struct _NT_PEB32
	{
		BYTE	Reserved1[2];
		BYTE	BeingDebugged;
		BYTE	Reserved2[1];
		PTR32	Reserved3[2];
		PTR32	Ldr;
		PTR32	ProcessParameters;
		PTR32	Reserved4[3];
		PTR32	AtlThunkSListPtr;
		PTR32	Reserved5;
		UINT32	Reserved6;
		PTR32	Reserved7;
		UINT32	Reserved8;
		UINT32	AtlThunkSListPtr32;
		PTR32	Reserved9[45];
		BYTE	Reserved10[96];
		PTR32	PostProcessInitRoutine;//PPS_POST_PROCESS_INIT_ROUTINE
		BYTE	Reserved11[128];
		PTR32	Reserved12[1];
		UINT32	SessionId;
	} NT_PEB32, *PNT_PEB32;

	typedef struct _NT_PEB64
	{
		BYTE	Reserved1[2];
		BYTE	BeingDebugged;
		BYTE	Reserved2[1];
		PTR64	Reserved3[2];
		PTR64	Ldr;
		PTR64	ProcessParameters;
		PTR64	Reserved4[3];
		PTR64	AtlThunkSListPtr;
		PTR64	Reserved5;
		UINT32	Reserved6;
		PTR64	Reserved7;
		UINT32	Reserved8;
		UINT32	AtlThunkSListPtr32;
		PTR64	Reserved9[45];
		BYTE	Reserved10[96];
		PTR64	PostProcessInitRoutine;//PPS_POST_PROCESS_INIT_ROUTINE
		BYTE	Reserved11[128];
		PTR64	Reserved12[1];
		UINT32	SessionId;
	} NT_PEB64, *PNT_PEB64;

	/***********************************************************************
	 * PEB data structure
	 */

	typedef struct _UNICODESTR32 {
		USHORT Length;
		USHORT MaximumLength;
		PTR32  Buffer;
	} UNICODESTR32;

	typedef struct _UNICODESTR64 {
		USHORT	Length;
		USHORT	MaximumLength;
		PTR64	Buffer;
	} UNICODESTR64;

	typedef struct _PEB_LDR_DATA32
	{
		ULONG				Length;
		BOOLEAN				Initialized;
		PTR32				SsHandle;
		LIST_ENTRY32		InLoadOrderModuleList;
		LIST_ENTRY32		InMemoryOrderModuleList;
		LIST_ENTRY32		InInitializationOrderModuleList;
	} PEB_LDR_DATA32, *PPEB_LDR_DATA32;
	
	typedef struct _PEB_LDR_DATA64
	{
		ULONG				Length;
		BOOLEAN				Initialized;
		PTR64				SsHandle;
		LIST_ENTRY64		InLoadOrderModuleList;
		LIST_ENTRY64		InMemoryOrderModuleList;
		LIST_ENTRY64		InInitializationOrderModuleList;
	} PEB_LDR_DATA64, *PPEB_LDR_DATA64;


	typedef struct _PEB32
	{																 /* win32/win64 */
		BOOLEAN						InheritedAddressSpace;			 /* 000/000 */
		BOOLEAN						ReadImageFileExecOptions;		  /* 001/001 */
		BOOLEAN						BeingDebugged;					 /* 002/002 */
		BOOLEAN						SpareBool;						 /* 003/003 */
		PTR32						Mutant;							/* 004/008 */
		PTR32						ImageBaseAddress;				  /* 008/010 */
		PTR32						LdrData;							/* 00c/018 */
		PTR32						ProcessParameters;				 /* 010/020 */
		PTR32						SubSystemData;					 /* 014/028 */
		PTR32						ProcessHeap;						/* 018/030 */
		PTR32						FastPebLock;						/* 01c/038 */
		PTR32 /*PPEBLOCKROUTINE*/	FastPebLockRoutine;				/* 020/040 */
		PTR32 /*PPEBLOCKROUTINE*/	FastPebUnlockRoutine;			  /* 024/048 */
		UINT32						EnvironmentUpdateCount;			/* 028/050 */
		PTR32						KernelCallbackTable;				/* 02c/058 */
		UINT32						Reserved[2];						/* 030/060 */
		PTR32 /*PPEB_FREE_BLOCK*/	FreeList;						  /* 038/068 */
		UINT32						TlsExpansionCounter;				/* 03c/070 */
		PTR32						TlsBitmap;						 /* 040/078 */
		UINT32						TlsBitmapBits[2];				  /* 044/080 */
		PTR32						ReadOnlySharedMemoryBase;		  /* 04c/088 */
		PTR32						ReadOnlySharedMemoryHeap;		  /* 050/090 */
		PTR32						ReadOnlyStaticServerData;		  /* 054/098 */
		PTR32						AnsiCodePageData;				  /* 058/0a0 */
		PTR32						OemCodePageData;					/* 05c/0a8 */
		PTR32						UnicodeCaseTableData;			  /* 060/0b0 */
		UINT32						NumberOfProcessors;				/* 064/0b8 */
		UINT32						NtGlobalFlag;					  /* 068/0bc */
		LARGE_INTEGER				CriticalSectionTimeout;			/* 070/0c0 */
		UINT32						HeapSegmentReserve;				/* 078/0c8 */
		UINT32						HeapSegmentCommit;				 /* 07c/0d0 */
		UINT32						HeapDeCommitTotalFreeThreshold;	/* 080/0d8 */
		UINT32						HeapDeCommitFreeBlockThreshold;	/* 084/0e0 */
		UINT32						NumberOfHeaps;					 /* 088/0e8 */
		UINT32						MaximumNumberOfHeaps;			  /* 08c/0ec */
		PTR32						ProcessHeaps;					  /* 090/0f0 */
		PTR32						GdiSharedHandleTable;			  /* 094/0f8 */
		PTR32						ProcessStarterHelper;			  /* 098/100 */
		PTR32						GdiDCAttributeList;				/* 09c/108 */
		PTR32						LoaderLock;						/* 0a0/110 */
		UINT32						OSMajorVersion;					/* 0a4/118 */
		UINT32						OSMinorVersion;					/* 0a8/11c */
		UINT32						OSBuildNumber;					 /* 0ac/120 */
		UINT32						OSPlatformId;					  /* 0b0/124 */
		UINT32						ImageSubSystem;					/* 0b4/128 */
		UINT32						ImageSubSystemMajorVersion;		/* 0b8/12c */
		UINT32						ImageSubSystemMinorVersion;		/* 0bc/130 */
		UINT32						ImageProcessAffinityMask;		  /* 0c0/134 */
		PTR32						GdiHandleBuffer[28];				/* 0c4/138 */
		UINT32						unknown[6];						/* 134/218 */
		PTR32						PostProcessInitRoutine;			/* 14c/230 */
		PTR32						TlsExpansionBitmap;				/* 150/238 */
		UINT32						TlsExpansionBitmapBits[32];		/* 154/240 */
		UINT32						SessionId;						 /* 1d4/2c0 */
		ULARGE_INTEGER				AppCompatFlags;					/* 1d8/2c8 */
		ULARGE_INTEGER				AppCompatFlagsUser;				/* 1e0/2d0 */
		PTR32						ShimData;						  /* 1e8/2d8 */
		PTR32						AppCompatInfo;					 /* 1ec/2e0 */
		UNICODESTR32				CSDVersion;						/* 1f0/2e8 */
		PTR32						ActivationContextData;			 /* 1f8/2f8 */
		PTR32						ProcessAssemblyStorageMap;		 /* 1fc/300 */
		PTR32						SystemDefaultActivationData;		/* 200/308 */
		PTR32						SystemAssemblyStorageMap;		  /* 204/310 */
		UINT32						MinimumStackCommit;				/* 208/318 */
		PTR32						FlsCallback;						/* 20c/320 */
		LIST_ENTRY32				FlsListHead;						/* 210/328 */
		PTR32						FlsBitmap;						 /* 218/338 */
		UINT32						FlsBitmapBits[4];				  /* 21c/340 */
	} PEB32, *PPEB32;

	typedef struct _PEB64
	{																 /* win32/win64 */
		BOOLEAN						InheritedAddressSpace;			 /* 000/000 */
		BOOLEAN						ReadImageFileExecOptions;		  /* 001/001 */
		BOOLEAN						BeingDebugged;					 /* 002/002 */
		BOOLEAN						SpareBool;						 /* 003/003 */
		PTR64						Mutant;							/* 004/008 */
		PTR64						ImageBaseAddress;				  /* 008/010 */
		PTR64						LdrData;							/* 00c/018 */
		PTR64						ProcessParameters;				 /* 010/020 */
		PTR64						SubSystemData;					 /* 014/028 */
		PTR64						ProcessHeap;						/* 018/030 */
		PTR64						FastPebLock;						/* 01c/038 */
		PTR64 /*PPEBLOCKROUTINE*/	FastPebLockRoutine;				/* 020/040 */
		PTR64 /*PPEBLOCKROUTINE*/	FastPebUnlockRoutine;			  /* 024/048 */
		UINT32						EnvironmentUpdateCount;			/* 028/050 */
		PTR64						KernelCallbackTable;				/* 02c/058 */
		UINT32						Reserved[2];						/* 030/060 */
		PTR64 /*PPEB_FREE_BLOCK*/	FreeList;						  /* 038/068 */
		UINT32						TlsExpansionCounter;				/* 03c/070 */
		PTR64						TlsBitmap;						 /* 040/078 */
		UINT32						TlsBitmapBits[2];				  /* 044/080 */
		PTR64						ReadOnlySharedMemoryBase;		  /* 04c/088 */
		PTR64						ReadOnlySharedMemoryHeap;		  /* 050/090 */
		PTR64						ReadOnlyStaticServerData;		  /* 054/098 */
		PTR64						AnsiCodePageData;				  /* 058/0a0 */
		PTR64						OemCodePageData;					/* 05c/0a8 */
		PTR64						UnicodeCaseTableData;			  /* 060/0b0 */
		UINT32						NumberOfProcessors;				/* 064/0b8 */
		UINT32						NtGlobalFlag;					  /* 068/0bc */
		LARGE_INTEGER				CriticalSectionTimeout;			/* 070/0c0 */
		UINT64						HeapSegmentReserve;				/* 078/0c8 */
		UINT64						HeapSegmentCommit;				 /* 07c/0d0 */
		UINT64						HeapDeCommitTotalFreeThreshold;	/* 080/0d8 */
		UINT64						HeapDeCommitFreeBlockThreshold;	/* 084/0e0 */
		UINT32						NumberOfHeaps;					 /* 088/0e8 */
		UINT32						MaximumNumberOfHeaps;			  /* 08c/0ec */
		PTR64						ProcessHeaps;					  /* 090/0f0 */
		PTR64						GdiSharedHandleTable;			  /* 094/0f8 */
		PTR64						ProcessStarterHelper;			  /* 098/100 */
		PTR64						GdiDCAttributeList;				/* 09c/108 */
		PTR64						LoaderLock;						/* 0a0/110 */
		UINT32						OSMajorVersion;					/* 0a4/118 */
		UINT32						OSMinorVersion;					/* 0a8/11c */
		UINT32						OSBuildNumber;					 /* 0ac/120 */
		UINT32						OSPlatformId;					  /* 0b0/124 */
		UINT32						ImageSubSystem;					/* 0b4/128 */
		UINT32						ImageSubSystemMajorVersion;		/* 0b8/12c */
		UINT32						ImageSubSystemMinorVersion;		/* 0bc/130 */
		UINT32						ImageProcessAffinityMask;		  /* 0c0/134 */
		PTR64						GdiHandleBuffer[28];				/* 0c4/138 */
		UINT32						unknown[6];						/* 134/218 */
		PTR64						PostProcessInitRoutine;			/* 14c/230 */
		PTR64						TlsExpansionBitmap;				/* 150/238 */
		UINT32						TlsExpansionBitmapBits[32];		/* 154/240 */
		UINT32						SessionId;						 /* 1d4/2c0 */
		ULARGE_INTEGER				AppCompatFlags;					/* 1d8/2c8 */
		ULARGE_INTEGER				AppCompatFlagsUser;				/* 1e0/2d0 */
		PTR64						ShimData;						  /* 1e8/2d8 */
		PTR64						AppCompatInfo;					 /* 1ec/2e0 */
		UNICODESTR64				CSDVersion;						/* 1f0/2e8 */
		PTR64						ActivationContextData;			 /* 1f8/2f8 */
		PTR64						ProcessAssemblyStorageMap;		 /* 1fc/300 */
		PTR64						SystemDefaultActivationData;		/* 200/308 */
		PTR64						SystemAssemblyStorageMap;		  /* 204/310 */
		PTR64						MinimumStackCommit;				/* 208/318 */
		PTR64						FlsCallback;						/* 20c/320 */
		LIST_ENTRY64				FlsListHead;						/* 210/328 */
		PTR64						FlsBitmap;						 /* 218/338 */
		UINT32						FlsBitmapBits[4];				  /* 21c/340 */
	} PEB64, *PPEB64;
	

	typedef struct _EXCEPTION_REGISTRATION_RECORD32 
	{
		PTR32 Next;			// _EXCEPTION_REGISTRATION_RECORD32
		PTR32 Handler;		// PEXCEPTION_ROUTINE
	} EXCEPTION_REGISTRATION_RECORD32;

	typedef struct _EXCEPTION_REGISTRATION_RECORD64 
	{
		PTR64 Next;			// _EXCEPTION_REGISTRATION_RECORD32
		PTR64 Handler;		// PEXCEPTION_ROUTINE
	} EXCEPTION_REGISTRATION_RECORD64;

	typedef struct _TIB32 
	{
		PTR32	ExceptionList;			// EXCEPTION_REGISTRATION_RECORD32
		PTR32	StackBase;
		PTR32	StackLimit;
		PTR32	SubSystemTib;
		PTR32	FiberData;
		PTR32	ArbitraryUserPointer;
		PTR32	Self;
	} TIB32,  *PTIB32;

	typedef struct _TIB64
	{
		PTR64	ExceptionList;
		PTR64	StackBase;
		PTR64	StackLimit;
		PTR64	SubSystemTib;
		PTR64	FiberData;
		PTR64	ArbitraryUserPointer;
		PTR64	Self;
	} TIB64, *PTIB64;

	typedef struct _CLIENT_ID32
	{
		PTR32	UniqueProcess;
		PTR32	UniqueThread;
	} CLIENT_ID32, *PCLIENT_ID32;

	typedef struct _CLIENT_ID64
	{
		PTR64	UniqueProcess;
		PTR64	UniqueThread;
	} CLIENT_ID64, *PCLIENT_ID64;

	typedef struct _GDI_TEB_BATCH32
	{
		ULONG	Offset;
		PTR32	HDC;
		ULONG	Buffer[0x136];
	} GDI_TEB_BATCH32;

	typedef struct _GDI_TEB_BATCH64
	{
		ULONG	Offset;
		PTR64	HDC;
		ULONG	Buffer[0x136];
	} GDI_TEB_BATCH64;

	typedef struct _RTL_ACTIVATION_CONTEXT_STACK_FRAME32
	{
		PTR32	Previous;				// _RTL_ACTIVATION_CONTEXT_STACK_FRAME*
		PTR32	ActivationContext;		// _ACTIVATION_CONTEXT
		ULONG	Flags;
	} RTL_ACTIVATION_CONTEXT_STACK_FRAME32, *PRTL_ACTIVATION_CONTEXT_STACK_FRAME32;

	typedef struct _RTL_ACTIVATION_CONTEXT_STACK_FRAME64
	{
		PTR64			Previous;				// _RTL_ACTIVATION_CONTEXT_STACK_FRAME*
		PTR64			ActivationContext;		// _ACTIVATION_CONTEXT
		ULONG			Flags;
	} RTL_ACTIVATION_CONTEXT_STACK_FRAME64, *PRTL_ACTIVATION_CONTEXT_STACK_FRAME64;

	typedef struct _ACTIVATION_CONTEXT_STACK32
	{
		ULONG			Flags;
		ULONG			NextCookieSequenceNumber;
		PTR32			ActiveFrame;				// RTL_ACTIVATION_CONTEXT_STACK_FRAME
		LIST_ENTRY32	FrameListCache;
	} ACTIVATION_CONTEXT_STACK, *PACTIVATION_CONTEXT_STACK;


	typedef struct _ACTIVATION_CONTEXT_STACK64
	{
		ULONG			Flags;
		ULONG			NextCookieSequenceNumber;
		PTR64			ActiveFrame;
		LIST_ENTRY64	FrameListCache;
	} ACTIVATION_CONTEXT_STACK64, *PACTIVATION_CONTEXT_STACK64;


	/***********************************************************************
	 * TEB data structure
	 */
	typedef struct _TEB32
	{																	/* win32/win64 */
		TIB32						Tib;								/* 000/0000 */
		PTR32						EnvironmentPointer;					/* 01c/0038 */
		CLIENT_ID32					ClientId;							/* 020/0040 */
		PTR32						ActiveRpcHandle;					/* 028/0050 */
		PTR32						ThreadLocalStoragePointer;			/* 02c/0058 */
		PTR32						Peb;								/* 030/0060 */
		ULONG						LastErrorValue;						/* 034/0068 */
		ULONG						CountOfOwnedCriticalSections;		/* 038/006c */
		PTR32						CsrClientThread;					/* 03c/0070 */
		PTR32						Win32ThreadInfo;					/* 040/0078 */
		ULONG						Win32ClientInfo[31];				/* 044/0080 used for user32 private data in Wine */
		PTR32						WOW32Reserved;						/* 0c0/0100 */
		ULONG						CurrentLocale;						/* 0c4/0108 */
		ULONG						FpSoftwareStatusRegister;			/* 0c8/010c */
		PTR32						SystemReserved1[54];				/* 0cc/0110 used for kernel32 private data in Wine */
		LONG						ExceptionCode;						/* 1a4/02c0 */
		ACTIVATION_CONTEXT_STACK	ActivationContextStack;				/* 1a8/02c8 */
		BYTE						SpareBytes1[24];					/* 1bc/02e8 used for ntdll private data in Wine */
		PTR32						SystemReserved2[10];				/* 1d4/0300 used for ntdll private data in Wine */
		GDI_TEB_BATCH32				GdiTebBatch;						/* 1fc/0350 used for vm86 private data in Wine */
		PTR32						gdiRgn;								/* 6dc/0838 */
		PTR32						gdiPen;								/* 6e0/0840 */
		PTR32						gdiBrush;							/* 6e4/0848 */
		CLIENT_ID32					RealClientId;						/* 6e8/0850 */
		PTR32						GdiCachedProcessHandle;				/* 6f0/0860 */
		ULONG						GdiClientPID;						/* 6f4/0868 */
		ULONG						GdiClientTID;						/* 6f8/086c */
		PTR32						GdiThreadLocaleInfo;				/* 6fc/0870 */
		ULONG						UserReserved[5];					/* 700/0878 */
		PTR32						glDispachTable[280];				/* 714/0890 */
		PTR32						glReserved1[26];					/* b74/1150 */
		PTR32						glReserved2;						/* bdc/1220 */
		PTR32						glSectionInfo;						/* be0/1228 */
		PTR32						glSection;							/* be4/1230 */
		PTR32						glTable;							/* be8/1238 */
		PTR32						glCurrentRC;						/* bec/1240 */
		PTR32						glContext;							/* bf0/1248 */
		ULONG						LastStatusValue;					/* bf4/1250 */
		UNICODESTR32				StaticUnicodeString;				/* bf8/1258 used by advapi32 */
		WCHAR						StaticUnicodeBuffer[261];			/* c00/1268 used by advapi32 */
		PTR32						DeallocationStack;					/* e0c/1478 */
		PTR32						TlsSlots[64];						/* e10/1480 */
		LIST_ENTRY32				TlsLinks;							/* f10/1680 */
		PTR32						Vdm;								/* f18/1690 */
		PTR32						ReservedForNtRpc;					/* f1c/1698 */
		PTR32						DbgSsReserved[2];					/* f20/16a0 */
		ULONG						HardErrorDisabled;					/* f28/16b0 */
		PTR32						Instrumentation[16];				/* f2c/16b8 */
		PTR32						WinSockData;						/* f6c/1738 */
		ULONG						GdiBatchCount;						/* f70/1740 */
		ULONG						Spare2;								/* f74/1744 */
		PTR32						Spare3;								/* f78/1748 */
		PTR32						Spare4;								/* f7c/1750 */
		PTR32						ReservedForOle;						/* f80/1758 */
		ULONG						WaitingOnLoaderLock;				/* f84/1760 */
		PTR32						Reserved5[3];						/* f88/1768 */
		PTR32						TlsExpansionSlots;					/* f94/1780 */
		ULONG						ImpersonationLocale;				/* f98/1788 */
		ULONG						IsImpersonating;					/* f9c/178c */
		PTR32						NlsCache;							/* fa0/1790 */
		PTR32						ShimData;							/* fa4/1798 */
		ULONG						HeapVirtualAffinity;				/* fa8/17a0 */
		PTR32						CurrentTransactionHandle;			/* fac/17a8 */
		PTR32						ActiveFrame;						/* fb0/17b0 */
		PTR32						FlsSlots;							/* fb4/17c8 */
	} TEB32, *PTEB32;

	/***********************************************************************
	 * TEB data structure
	 */

	typedef struct _NT_TEB32 {
		PVOID Reserved1[12];
		PNT_PEB32 ProcessEnvironmentBlock;
		PVOID Reserved2[399];
		BYTE Reserved3[1952];
		PVOID TlsSlots[64];
		BYTE Reserved4[8];
		PVOID Reserved5[26];
		PVOID ReservedForOle;  // Windows 2000 only
		PVOID Reserved6[4];
		PVOID TlsExpansionSlots;
	} NT_TEB32, *PNT_TEB32;

	typedef struct _TEB64
	{																/* win32/win64 */
		TIB64						Tib;							/* 000/0000 */
		PTR64						EnvironmentPointer;				/* 01c/0038 */
		CLIENT_ID64					ClientId;						/* 020/0040 */
		PTR64						ActiveRpcHandle;				/* 028/0050 */
		PTR64						ThreadLocalStoragePointer;		/* 02c/0058 */
		PTR64						Peb;							/* 030/0060 */
		ULONG						LastErrorValue;					/* 034/0068 */
		ULONG						CountOfOwnedCriticalSections;	/* 038/006c */
		PTR64						CsrClientThread;				/* 03c/0070 */
		PTR64						Win32ThreadInfo;				/* 040/0078 */
		ULONG						Win32ClientInfo[31];			/* 044/0080 used for user32 private data in Wine */
		PTR64						WOW32Reserved;					/* 0c0/0100 */
		ULONG						CurrentLocale;					/* 0c4/0108 */
		ULONG						FpSoftwareStatusRegister;		/* 0c8/010c */
		PTR64						SystemReserved1[54];			/* 0cc/0110 used for kernel32 private data in Wine */
		LONG						ExceptionCode;					/* 1a4/02c0 */
		ACTIVATION_CONTEXT_STACK64	ActivationContextStack;			/* 1a8/02c8 */
		BYTE						SpareBytes1[24];				/* 1bc/02e8 used for ntdll private data in Wine */
		PTR64						SystemReserved2[10];			/* 1d4/0300 used for ntdll private data in Wine */
		GDI_TEB_BATCH64				GdiTebBatch;					/* 1fc/0350 used for vm86 private data in Wine */
		PTR64						gdiRgn;							/* 6dc/0838 */
		PTR64						gdiPen;							/* 6e0/0840 */
		PTR64						gdiBrush;						/* 6e4/0848 */
		CLIENT_ID64					RealClientId;					/* 6e8/0850 */
		PTR64						GdiCachedProcessHandle;			/* 6f0/0860 */
		ULONG						GdiClientPID;					/* 6f4/0868 */
		ULONG						GdiClientTID;					/* 6f8/086c */
		PTR64						GdiThreadLocaleInfo;			/* 6fc/0870 */
		ULONG						UserReserved[5];				/* 700/0878 */
		PTR64						glDispachTable[280];			/* 714/0890 */
		PTR64						glReserved1[26];				/* b74/1150 */
		PTR64						glReserved2;					/* bdc/1220 */
		PTR64						glSectionInfo;					/* be0/1228 */
		PTR64						glSection;						/* be4/1230 */
		PTR64						glTable;						/* be8/1238 */
		PTR64						glCurrentRC;					/* bec/1240 */
		PTR64						glContext;						/* bf0/1248 */
		ULONG						LastStatusValue;				/* bf4/1250 */
		UNICODESTR64				StaticUnicodeString;			/* bf8/1258 used by advapi32 */
		WCHAR						StaticUnicodeBuffer[261];		/* c00/1268 used by advapi32 */
		PTR64						DeallocationStack;				/* e0c/1478 */
		PTR64						TlsSlots[64];					/* e10/1480 */
		LIST_ENTRY64				TlsLinks;						/* f10/1680 */
		PTR64						Vdm;							/* f18/1690 */
		PTR64						ReservedForNtRpc;				/* f1c/1698 */
		PTR64						DbgSsReserved[2];				/* f20/16a0 */
		ULONG						HardErrorDisabled;				/* f28/16b0 */
		PTR64						Instrumentation[16];			/* f2c/16b8 */
		PTR64						WinSockData;					/* f6c/1738 */
		ULONG						GdiBatchCount;					/* f70/1740 */
		ULONG						Spare2;							/* f74/1744 */
		PTR64						Spare3;							/* f78/1748 */
		PTR64						Spare4;							/* f7c/1750 */
		PTR64						ReservedForOle;					/* f80/1758 */
		ULONG						WaitingOnLoaderLock;			/* f84/1760 */
		PTR64						Reserved5[3];					/* f88/1768 */
		PTR64						TlsExpansionSlots;				/* f94/1780 */
		ULONG						ImpersonationLocale;			/* f98/1788 */
		ULONG						IsImpersonating;				/* f9c/178c */
		PTR64						NlsCache;						/* fa0/1790 */
		PTR64						ShimData;						/* fa4/1798 */
		ULONG						HeapVirtualAffinity;			/* fa8/17a0 */
		PTR64						CurrentTransactionHandle;		/* fac/17a8 */
		PTR64						ActiveFrame;					/* fb0/17b0 */
		PTR64						FlsSlots;						/* fb4/17c8 */
	} TEB64, *PTEB64;

	//////////////////////////////////////////////////////////////////////////
	//
	//	Exception
	//

	typedef struct _EXCEPTION_RECORD32 {
		DWORD	 ExceptionCode;
		DWORD	 ExceptionFlags;
		PTR32	 ExceptionRecord;
		PTR32	 ExceptionAddress;
		DWORD	 NumberParameters;
		PTR32	 ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
	} EXCEPTION_RECORD32, *PEXCEPTION_RECORD32;

	typedef struct _EXCEPTION_RECORD64 {
		DWORD	ExceptionCode;
		DWORD	ExceptionFlags;
		PTR64	ExceptionRecord;
		PTR64	ExceptionAddress;
		DWORD	NumberParameters;
		DWORD	__unusedAlignment;
		PTR64	ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
	} EXCEPTION_RECORD64, *PEXCEPTION_RECORD64;

	typedef union _X_EXCEPTION_RECORD
	{
		EXCEPTION_RECORD32	x86;
		EXCEPTION_RECORD64	x64;
	} XEXCEPTION_RECORD;

	//////////////////////////////////////////////////////////////////////////

	/*************************************************************************
	 * Loader structures
	 *
	 * Those are not part of standard Winternl.h
	 */
	typedef struct _LDR_MODULE32
	{
		LIST_ENTRY32		InLoadOrderModuleList;
		LIST_ENTRY32		InMemoryOrderModuleList;
		LIST_ENTRY32		InInitializationOrderModuleList;
		PTR32				BaseAddress;
		PTR32				EntryPoint;
		ULONG				SizeOfImage;
		UNICODE_STRING32	FullDllName;
		UNICODE_STRING32	BaseDllName;
		ULONG				Flags;
		SHORT				LoadCount;
		SHORT				TlsIndex;
		PTR32				SectionHandle;
		ULONG				CheckSum;
		ULONG				TimeDateStamp;
		PTR32				ActivationContext;
	} LDR_MODULE32, *PLDR_MODULE32;

	//////////////////////////////////////////////////////////////////////////

	typedef struct _LDR_MODULE64
	{
		LIST_ENTRY64		InLoadOrderModuleList;
		LIST_ENTRY64		InMemoryOrderModuleList;
		LIST_ENTRY64		InInitializationOrderModuleList;
		PTR64				BaseAddress;
		PTR64				EntryPoint;
		ULONG				SizeOfImage;
		UNICODE_STRING64	FullDllName;
		UNICODE_STRING64	BaseDllName;
		ULONG				Flags;
		SHORT				LoadCount;
		SHORT				TlsIndex;
		PTR64				SectionHandle;
		ULONG				CheckSum;
		ULONG				TimeDateStamp;
		PTR64				ActivationContext;
	} LDR_MODULE64, *PLDR_MODULE64;

	/* those defines are (some of the) regular LDR_MODULE.Flags values */
	enum 
	{
		LDR_IMAGE_IS_DLL		= 0x00000004,
		LDR_LOAD_IN_PROGRESS	= 0x00001000,
		LDR_UNLOAD_IN_PROGRESS	= 0x00002000,
		LDR_NO_DLL_CALLS		= 0x00040000,
		LDR_PROCESS_ATTACHED	= 0x00080000,
		LDR_MODULE_REBASED		= 0x00200000,

	/* these ones is Wine specific */
		LDR_DONT_RESOLVE_REFS	= 0x40000000,
		LDR_WINE_INTERNAL		= 0x80000000,

	/* flag for LdrAddRefDll */
		LDR_ADDREF_DLL_PIN		= 0x00000001,

	/* FIXME: to be checked */
		MAXIMUM_FILENAME_LENGTH = 256,
	};

	typedef struct _CURDIR32
	{
		UNICODE_STRING32	DosPath;
		PTR32				Handle;
	} CURDIR32, *PCURDIR32;

	typedef struct _CURDIR64
	{
		UNICODE_STRING64	DosPath;
		PTR64				Handle;
	} CURDIR64, *PCURDIR64;
	
	typedef struct RTL_DRIVE_LETTER_CURDIR32
	{
		USHORT						Flags;
		USHORT						Length;
		ULONG						TimeStamp;
		UNICODE_STRING32			DosPath;
	} RTL_DRIVE_LETTER_CURDIR32, *PRTL_DRIVE_LETTER_CURDIR32;

	typedef struct RTL_DRIVE_LETTER_CURDIR64
	{
		USHORT						Flags;
		USHORT						Length;
		ULONG						TimeStamp;
		UNICODE_STRING64			DosPath;
	} RTL_DRIVE_LETTER_CURDIR64, *PRTL_DRIVE_LETTER_CURDIR64;

	typedef struct _RTL_USER_PROCESS_PARAMETERS32
	{
		ULONG						AllocationSize;
		ULONG						Size;
		ULONG						Flags;
		ULONG						DebugFlags;
		PTR32						ConsoleHandle;
		ULONG						ConsoleFlags;
		PTR32						hStdInput;
		PTR32						hStdOutput;
		PTR32						hStdError;
		CURDIR32					CurrentDirectory;
		UNICODE_STRING32			DllPath;
		UNICODE_STRING32			ImagePathName;
		UNICODE_STRING32			CommandLine;
		PTR32						Environment;
		ULONG						dwX;
		ULONG						dwY;
		ULONG						dwXSize;
		ULONG						dwYSize;
		ULONG						dwXCountChars;
		ULONG						dwYCountChars;
		ULONG						dwFillAttribute;
		ULONG						dwFlags;
		ULONG						wShowWindow;
		UNICODE_STRING32			WindowTitle;
		UNICODE_STRING32			Desktop;
		UNICODE_STRING32			ShellInfo;
		UNICODE_STRING32			RuntimeInfo;
		RTL_DRIVE_LETTER_CURDIR32	DLCurrentDirectory[0x20];
	} RTL_USER_PROCESS_PARAMETERS32, *PRTL_USER_PROCESS_PARAMETERS32;

	typedef struct _RTL_USER_PROCESS_PARAMETERS64
	{
		ULONG						AllocationSize;
		ULONG						Size;
		ULONG						Flags;
		ULONG						DebugFlags;
		PTR64						ConsoleHandle;
		ULONG						ConsoleFlags;
		PTR64						hStdInput;
		PTR64						hStdOutput;
		PTR64						hStdError;
		CURDIR64					CurrentDirectory;
		UNICODE_STRING64			DllPath;
		UNICODE_STRING64			ImagePathName;
		UNICODE_STRING64			CommandLine;
		PTR64						Environment;
		ULONG						dwX;
		ULONG						dwY;
		ULONG						dwXSize;
		ULONG						dwYSize;
		ULONG						dwXCountChars;
		ULONG						dwYCountChars;
		ULONG						dwFillAttribute;
		ULONG						dwFlags;
		ULONG						wShowWindow;
		UNICODE_STRING64			WindowTitle;
		UNICODE_STRING64			Desktop;
		UNICODE_STRING64			ShellInfo;
		UNICODE_STRING64			RuntimeInfo;
		RTL_DRIVE_LETTER_CURDIR64	DLCurrentDirectory[0x20];
	} RTL_USER_PROCESS_PARAMETERS64, *PRTL_USER_PROCESS_PARAMETERS64;

#define GUEST_NT_VERSION		NTDDI_WIN7
#define _ANONYMOUS_UNION
#define _ANONYMOUS_STRUCT
#define PROCESSOR_FEATURE_MAX 64

	typedef struct _KSYSTEM_TIME {
		ULONG LowPart;
		LONG High1Time;
		LONG High2Time;
	} KSYSTEM_TIME, *PKSYSTEM_TIME;

	typedef enum _NT_PRODUCT_TYPE {
		NtProductWinNt = 1,
		NtProductLanManNt,
		NtProductServer
	} NT_PRODUCT_TYPE, *PNT_PRODUCT_TYPE;

	typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE
	{
		StandardDesign,
		NEC98x86,
		EndAlternatives
	} ALTERNATIVE_ARCHITECTURE_TYPE;

	#define MAX_WOW64_SHARED_ENTRIES 16

	typedef struct _KUSER_SHARED_DATA {
		ULONG TickCountLowDeprecated;
		ULONG TickCountMultiplier;
		volatile KSYSTEM_TIME InterruptTime;
		volatile KSYSTEM_TIME SystemTime;
		volatile KSYSTEM_TIME TimeZoneBias;
		USHORT ImageNumberLow;
		USHORT ImageNumberHigh;
		WCHAR NtSystemRoot[260];
		ULONG MaxStackTraceDepth;
		ULONG CryptoExponent;
		ULONG TimeZoneId;
		ULONG LargePageMinimum;
		ULONG Reserved2[7];
		NT_PRODUCT_TYPE NtProductType;
		BOOLEAN ProductTypeIsValid;
		ULONG NtMajorVersion;
		ULONG NtMinorVersion;
		BOOLEAN ProcessorFeatures[PROCESSOR_FEATURE_MAX];
		ULONG Reserved1;
		ULONG Reserved3;
		volatile ULONG TimeSlip;
		ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture;
		ULONG AltArchitecturePad[1];
		LARGE_INTEGER SystemExpirationDate;
		ULONG SuiteMask;
		BOOLEAN KdDebuggerEnabled;
	#if (GUEST_NT_VERSION >= NTDDI_WINXPSP2)
		UCHAR NXSupportPolicy;
	#endif
		volatile ULONG ActiveConsoleId;
		volatile ULONG DismountCount;
		ULONG ComPlusPackage;
		ULONG LastSystemRITEventTickCount;
		ULONG NumberOfPhysicalPages;
		BOOLEAN SafeBootMode;
	#if (GUEST_NT_VERSION >= NTDDI_WIN7)
	  _ANONYMOUS_UNION union {
		UCHAR TscQpcData;
		_ANONYMOUS_STRUCT struct {
		  UCHAR TscQpcEnabled:1;
		  UCHAR TscQpcSpareFlag:1;
		  UCHAR TscQpcShift:6;
		} DUMMYSTRUCTNAME;
	  } DUMMYUNIONNAME;
	  UCHAR TscQpcPad[2];
	#endif
	#if (GUEST_NT_VERSION >= NTDDI_VISTA)
	  _ANONYMOUS_UNION union {
		ULONG SharedDataFlags;
		_ANONYMOUS_STRUCT struct {
		  ULONG DbgErrorPortPresent:1;
		  ULONG DbgElevationEnabled:1;
		  ULONG DbgVirtEnabled:1;
		  ULONG DbgInstallerDetectEnabled:1;
		  ULONG DbgSystemDllRelocated:1;
		  ULONG DbgDynProcessorEnabled:1;
		  ULONG DbgSEHValidationEnabled:1;
		  ULONG SpareBits:25;
		} DUMMYSTRUCTNAME2;
	  } DUMMYUNIONNAME2;
	#else
	  ULONG TraceLogging;
	#endif
	  ULONG DataFlagsPad[1];
	  ULONGLONG TestRetInstruction;
	  ULONG SystemCall;
	  ULONG SystemCallReturn;
	  ULONGLONG SystemCallPad[3];
	  _ANONYMOUS_UNION union {
		volatile KSYSTEM_TIME TickCount;
		volatile ULONG64 TickCountQuad;
		_ANONYMOUS_STRUCT struct {
		  ULONG ReservedTickCountOverlay[3];
		  ULONG TickCountPad[1];
		} DUMMYSTRUCTNAME;
	  } DUMMYUNIONNAME3;
	  ULONG Cookie;
	  ULONG CookiePad[1];
	#if (GUEST_NT_VERSION >= NTDDI_WS03)
	  LONGLONG ConsoleSessionForegroundProcessId;
	  ULONG Wow64SharedInformation[MAX_WOW64_SHARED_ENTRIES];
	#endif
	#if (GUEST_NT_VERSION >= NTDDI_VISTA)
	#if (GUEST_NT_VERSION >= NTDDI_WIN7)
	  USHORT UserModeGlobalLogger[16];
	#else
	  USHORT UserModeGlobalLogger[8];
	  ULONG HeapTracingPid[2];
	  ULONG CritSecTracingPid[2];
	#endif
	  ULONG ImageFileExecutionOptions;
	#if (GUEST_NT_VERSION >= NTDDI_VISTASP1)
	  ULONG LangGenerationCount;
	#else
	  /* 4 bytes padding */
	#endif
	  ULONGLONG Reserved5;
	  volatile ULONG64 InterruptTimeBias;
	#endif
	#if (GUEST_NT_VERSION >= NTDDI_WIN7)
	  volatile ULONG64 TscQpcBias;
	  volatile ULONG ActiveProcessorCount;
	  volatile USHORT ActiveGroupCount;
	  USHORT Reserved4;
	  volatile ULONG AitSamplingValue;
	  volatile ULONG AppCompatFlag;
	  ULONGLONG SystemDllNativeRelocation;
	  ULONG SystemDllWowRelocation;
	  ULONG XStatePad[1];
	  XSTATE_CONFIGURATION XState;
	#endif
	} KUSER_SHARED_DATA, *PKUSER_SHARED_DATA;


};

#endif